function _initFlieUpload(uploadButtonId,queueId, basePath, fileidsId, buttonText,formData) {
	
	var btext = "选择文件";
	if (buttonText) {
		btext = buttonText;
	}
	
	$("#"+uploadButtonId).uploadify({
		'swf' : basePath+'/admin/ext/uploadify/uploadify.swf',
		'uploader' : basePath+'/fileUpload/upload.do',
		'buttonText' : btext,
		'width' : 100,
		'height' : 30,
		'formData':formData,
		'queueID': queueId,
		'buttonClass': 'btn btn-primary no-padding',
		'multi': true,
		'auto':true,
		'fileObjName':'filename',
		'fileSizeLimit' : '500MB',
		'removeCompleted':false,
        'overrideEvents': ['onSelectError', 'onDialogClose'],
        'onSelectError':function(file, errorCode, errorMsg){
            switch(errorCode) {
	            case -100:  
	                alert("上传的文件数量已经超出系统限制的" + $('#file_upload').uploadify('settings', 'queueSizeLimit') + "个文件！");  
	                break;  
            	case -110:
                    alert("文件 ["+file.name+"] 大小超出系统限制的" + jQuery('#file_upload').uploadify('settings', 'fileSizeLimit') + "大小！");
                    break;
                case -120:
                    alert("文件 ["+file.name+"] 大小异常！");
                    break;
                case -130:
                    alert("文件 ["+file.name+"] 类型不正确！");
                    break;
            }
        },
        'onSelect':function (event,queueId,fileObj){
        
        },
        'onQueueComplete':function(queueData){
        	
        },
        'onClearQueue': function(queueItemCount){
            console.log(queueItemCount+'file(s) were removed frome the queue')
        },
        'onFallback': function () {  
            alert("您未安装FLASH控件，无法上传！请安装FLASH控件后再试。");  
        },
        'onCancel':function (event,queueId,fileObj,data){
        	
        },
		'onUploadSuccess' : function(file, data, response) {
			var msg = $.parseJSON(data);
			if(1!=msg.s){
				$("#"+uploadButtonId).uploadify("cancel",file.id);
				alert(msg.d);
			}else{
				var a = $("#"+fileidsId).val().split(",");
				a.push(msg.d);
				$("#"+fileidsId).val(arraytostring(a));
				$("#"+file.id+" div a").attr("href","javascript:_deletefile('"+uploadButtonId+"','"+file.id+"',"+msg.d+",'"+fileidsId+"')");
			}
		}
    });
}

function _initFlieUpload_h5(showid,fileid,queueid, basePath, fileidsId,formData) {
	$('#'+showid).fileLoader({
		'width':100,
		'height':30,
        'file':'#'+fileid,
        'swf': basePath+'/admin/ext/uploadify/uploadify.swf',
    	'uri': basePath,
        'ajax': '/fileUpload/upload.ajax',
        'formData':formData,
        'fileObjName':'filename',
        'auto':true,
        'multi':true,
        'fileSileLimit':'500MB',
        'onUploadSuccess' : function(file, data, response) {
        	var msg = $.parseJSON(data);
			if(1!=msg.s){
				alert(msg.d);
			}else{
				var a = $("#"+fileidsId).val().split(",");
				a.push(msg.d);
				$("#"+fileidsId).val(arraytostring(a));
				$("#"+queueid).append('<span style="display:block;margin:5px 0px;" id="queue_id_'+msg.d+'" >'+file.name+'&nbsp;&nbsp;&nbsp;&nbsp;<a href="###" onclick="_deletefile_h5('+msg.d+',\''+fileidsId+'\');">移除</a></span>\n');
			}
		}
    });
}

function _initFlieUpload_h5_one(showid,fileid,queueid, basePath, fileidsId,formData) {
	$('#'+showid).fileLoader({
		'width':100,
		'height':30,
        'file':'#'+fileid,
        'swf': basePath+'/admin/ext/uploadify/uploadify.swf',
    	'uri': basePath,
        'ajax': '/file/upload.ajax',
        'formData':formData,
        'fileObjName':'filename',
        'auto':true,
        'multi':false,
        'fileSileLimit':'500MB',
        'onUploadSuccess' : function(file, data, response) {
        	var msg = $.parseJSON(data);
			if(1!=msg.s){
				alert("上传失败！");
			}else{
				$("#"+fileidsId).val(msg.d.savePath);
				$("#"+queueid).html('<span style="display:block;margin:5px 0px;" >'+file.name+'&nbsp;&nbsp;&nbsp;&nbsp;</span>\n');
			}
		}
    });
}

function _deletefile_h5(remove_id,fileidsId){
	var str = $("#"+fileidsId).val();
	var a = str.split(",");
	a.s_remove(remove_id);
	var removeObj = $("#queue_id_"+remove_id);
	removeObj.remove();
	$("#"+fileidsId).val(arraytostring(a));
}


function _deletefile(uploadButtonId,fileid,id,fileidsId){
	var str = $("#"+fileidsId).val();
	var a = str.split(",");
	a.s_remove(id);
	$("#"+fileidsId).val(arraytostring(a));
	$("#"+uploadButtonId).uploadify("cancel",fileid);
}

function arraytostring(arr){
	var str = "";
	for(var i =0 ;i<arr.length;i++){
		if(str!=""){
			str += ",";
		}
		str +=arr[i];
	}
	return str;
}



Array.prototype.s_indexOf = function(val) {              
    for (var i = 0; i < this.length; i++) {  
        if (this[i] == val) return i;  
    }  
    return -1;  
};  

Array.prototype.s_remove = function(val) {  
    var index = this.s_indexOf(val);  
    if (index > -1) {  
        this.splice(index, 1);  
    }  
};  